<template>
  <div class="father">
    <h2>props组件通信</h2>
    <h3>父组件</h3>
    <h4>汽车:{{ car }}</h4>
    <h4 v-show="toy">儿子给的玩具:{{ toy }}</h4>
    <!-- 传递给子 :car  :sendToy   父亲给子的是非函数-->
    <child :car="car" :sendToy="getToy" />
  </div>
</template>

<script setup lang="ts">
import Child from "./Child.vue";
import { ref } from "vue";

let car = ref("劳斯莱斯");
let toy = ref("");
//方法
function getToy(value: string) {
  console.log("父", value);
  toy.value = value;
}
</script>

<style scoped>
.father {
  background-color: orange;
  padding: 10px;
  box-shadow: 0 0 10px black;
  border-radius: 10px;
}
</style>
